<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../../base.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>数据 - AdminLTE2定制版</title>
</head>
<body>
<div id="frameContent" class="content-wrapper" style="margin-left:0px;">
    <section class="content-header">
        <h1>
            留言信息
            <small>留言管理</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home/main.do"><i class="fa fa-dashboard"></i> 首页</a></li>
        </ol>
    </section>
    <section class="content">
        <div class="box-body">
            <div class="nav-tabs-custom">
                <ul class="nav nav-tabs">
                    <li class="active">
                        <a href="#tab-form" data-toggle="tab">添加留言</a>
                    </li>
                </ul>
                <div class="tab-content">
                    <form id="editForm" action="/system/leaveWord/edit.do" method="post" enctype="multipart/form-data">

                        <input type="hidden" name="fromName" value="${fromName}">
                        <div class="tab-pane active" id="tab-form">
                            <div class="row data-type">
                                <div class="col-md-2 title">标题</div>
                                <div class="col-md-10 data">
                                    <input type="text" class="form-control" placeholder="标题" name="tittle" >
                                </div>
                                <div class="col-md-2 title">内容</div>
                                <div class="col-md-10 data">
                                    <input type="text" class="form-control" placeholder="内容" name="text" >
                                </div>

                                <div class="col-md-2 title">收件人信息</div>
                                <div class="col-md-10 data">

                                    <select id="dept"  name="dept" style="width:150px">
                                        <option value="">----请-选-择-部-门----</option>
                                        <c:forEach items="${deptList}" var="d">
                                            <option value="${d.id}">${d.deptName}</option>
                                        </c:forEach>

                                    </select>
                                    <select id="toName"  name="toName" style="width:180px">
                                        <option value="">----请-选-择-收-信-人----</option>
                                    </select>
                                </div>
                                <script>
                                    $("#dept").change(function () {
                                        // 复位（恢复默认）
                                        document.getElementById("toName").innerHTML=' <option value="">----请-选-择-收-信-人----</option>';
                                        let date="id="+ this.value;
                                        //alert(date)
                                        let url = '/system/leaveWord/toName.do';
                                        //alert(url)
                                        $.post(url,date,function (resp) {
                                            for (let user of  resp) {
                                            //$("#toName").innerHTML+=`<option value="\${user.id}">\${user.userName}</option>`;
                                                document.getElementById("toName").innerHTML+=`<option value="\${user.userName}">\${user.userName}</option>`;
                                            }
                                        })
                                    });
                                </script>

                                <div class="col-md-2 title"></div>
                                <div class="col-md-10 data text-center">
                                    <button type="button" onclick='document.getElementById("editForm").submit()'  class="btn bg-maroon">发送</button>
                                    <button type="button" class="btn bg-default" onclick="history.back(-1);">返回</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>

    </section>
</div>
<script>

</script>
</body>

</html>